package com.ywyself.controller.api;

import com.jfinal.core.ActionKey;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.ywyself.common.pool.DataPool;
import com.ywyself.controller.base.YsController;
import com.ywyself.ext.kit.YsKit;
import com.ywyself.service.DiaryService;

/**
 *
 * @author YuWenYue
 * @date 2017年11月7日 下午7:04:59
 */
public class ApiDiaryController extends YsController {

    @ActionKey("/api/diary")
    public void index() {
        int currentPageNumber = getParaToInt(0, 1);
        int pageSize = getParaToInt(1, DataPool.getPageSize());
        Page<Record> page = DiaryService.EXC.page(currentPageNumber, pageSize);
        YsKit.ok().set("page", currentPageNumber).set("totalPage", page.getTotalPage()).set("count", page.getTotalRow())
                .data(page.getList()).render(this);
    }

}
